<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitUpdate42 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('box_skus', function (Blueprint $table) {
            
            $table->renameColumn('probability_percent', 'odds');

            $table->tinyInteger('sku_type')->default(1)->comment('奖品类型, 1为自定义实物，2为绑定商城商品 3为平台虚拟资产  4为无任何奖品  5为抽奖次数');

            $table->json('assets')->nullable()->comment('当sku_type为2时，绑定的虚拟资产'); 
            $table->integer('product_id')->index()->nullable()->comment('当sku_type为1时, 绑定的商品id');
        });

        Schema::table('order_skus', function (Blueprint $table) {
            
            $table->renameColumn('product_type', 'base_sku_type');

            $table->dropColumn(['reward_money', 'reward_score', 'sku_type']);
        });

        Schema::table('order_skus', function (Blueprint $table) {
            $table->tinyInteger('sku_type')->default(1)->comment('奖品类型, 1为自定义实物，2为绑定商城商品 3为平台虚拟资产  4为无任何奖品');

            $table->string('activity_type', 20)->index()->nullable()->comment('对应活动类型, box yifanshang lottery egg_lottery');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('box_skus', function (Blueprint $table) {
            $table->renameColumn('odds', 'probability_percent');
            $table->dropColumn(['sku_type', 'assets', 'product_id']);
        });

        Schema::table('order_skus', function (Blueprint $table) {
            $table->renameColumn('base_sku_type', 'product_type');
        });
    }
}
